#define _CRT_SECURE_NO_WARNINGS 1
#include "slist.h"

void test()
{
	SLTNode* plist = NULL;
	SLTPushBack(&plist, 23);
	SLTPushBack(&plist, 46);
	SLTPushBack(&plist, 15);
	SLTPushBack(&plist, 24);
	SLTPrint(plist);

	SLTPushFront(&plist, 1);
	SLTPushFront(&plist, 2);
	SLTPushFront(&plist, 3);
	SLTPushFront(&plist, 4);
	SLTPushFront(&plist, 5);
	SLTPrint(plist);

	SLTPopBack(&plist);
	SLTPrint(plist);
	SLTPopBack(&plist);
	SLTPrint(plist);
	SLTPopBack(&plist);
	SLTPrint(plist);
	SLTPopBack(&plist);
	SLTPrint(plist);
	SLTPopBack(&plist);
	SLTPrint(plist);
	SLTPopBack(&plist);
	SLTPrint(plist);

	SLTPopFront(&plist);
	SLTPrint(plist);
	SLTPopFront(&plist);
	SLTPrint(plist);
	SLTPopFront(&plist);
	SLTPrint(plist);

}

void test2()
{
	SLTNode* plist = NULL;
	SLTPushBack(&plist, 23);
	SLTPushBack(&plist, 46);
	SLTPushBack(&plist, 15);
	SLTPushBack(&plist, 24);
	SLTPrint(plist);

	SLTPushFront(&plist, 1);
	SLTPushFront(&plist, 2);
	SLTPushFront(&plist, 3);
	SLTPushFront(&plist, 4);
	SLTPushFront(&plist, 5);
	SLTPrint(plist);

	int x = 0;

	//do
	//{
	//	scanf("%d", &x);
	//	SLTNode* pos = SLTFind(plist, x);
	//	SLTInsert(&plist, pos, x-1);
	//	SLTPrint(plist);
	//} while (x);

	do
	{
		scanf("%d", &x);
		SLTNode* pos = SLTFind(plist, x);
		SLTInsertAfter(pos, x - 1);
		SLTPrint(plist);
	} while (x);

	//do
	//{
	//	scanf("%d", &x);
	//	SLTNode* pos = SLTFind(plist, x);
	//	SLTErase(&plist, pos);
	//	SLTPrint(plist);
	//} while (x);

	//do
	//{
	//	scanf("%d", &x);
	//	SLTNode* pos = SLTFind(plist, x);
	//	SLTEraseAfter(pos);
	//	SLTPrint(plist);
	//} while (x);

	SLTDestroy(&plist);
}


int main()
{
	//test();
	test2();
	return 0;
}